package day4.Exer;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

public class Company {
    private String name;
    private String adress;
    private String telephone;
    private String scope;
    List st = new ArrayList();
    int count = 0;

    public Company() {
    }

    public Company(String name, String adress, String telephone, String scope) {
        this.name = name;
        this.adress = adress;
        this.telephone = telephone;
        this.scope = scope;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAdress() {
        return adress;
    }

    public void setAdress(String adress) {
        this.adress = adress;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getScope() {
        return scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }
//添加新员工
    public void add(Staff b) {
        if (st.contains(b)) {
            System.out.println("员工已存在");
        }
        st.add(b);
    }
//显示员工信息
    public void showinfo() {
        System.out.println("公司共有"+st.size()+"名员工");
        for (Object o : st) {
            System.out.println("姓名：" + ((Staff) o).getName() + "；性别：" + ((Staff) o).getSex() + "；年龄：" + ((Staff) o).getAge() + ";职位：" + ((Staff) o).getJob() + ";薪水：" + ((Staff) o).getSalary());
        }
    }
//开除员工
    public boolean dismiss(String disname) {
        Object s = new Staff(disname);
        if (st.contains(s)) {
                    st.remove(s);
                    System.out.println(disname + "已被开除！");
        }else{
            System.out.println("该员工不存在");
            return false;
        }

        return true;
    }
    public void findTopSalary() {
       Staff[]a=(Staff[]) st.toArray();
       int index=0;
       for(int i=0;i<st.size()-1;i++){
           if(a[i].getSalary()>=a[i+1].getSalary()){
               index=i;
           }else{
               index=i+1;
           }
       }
        System.out.println("工资最高的员工是"+a[index].getName());
    }



}
